<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/sys/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%@ include file="/WEB-INF/adminui/include/css.jsp" %>
<title>加工信息列表</title>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
	<div class="row">
		<div class="col-sm-2" style="width:20%">
			<div class="ibox ibox-body">
				<div class="ibox-title">
					<h5>选择地块</h5>
				</div>
				<div class="ibox-content">
					<div id="jstree"></div>
				</div>
			</div>
		</div>
		<div class="col-sm-10" style="width:78%">
			<div class="ibox">
				<div class="ibox-body">
					<div class="fixed-table-toolbar">
						<div id="toolbar" class="columns pull-left">
							<qx:perm code="plant_JG_ADD">
							<button type="button" class="btn btn-primary" onclick="add()" uilist-hide="PARK">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>添加
							</button>
							</qx:perm>
							<qx:perm code="plant_JG_DEL">
							<button type="button" class="btn btn-danger multi" onclick="del()">
								<i class="fa fa-trash hidden" aria-hidden="true"></i>删除
							</button>
							</qx:perm>
						</div>
						<div class="columns pull-right">
							<button class="btn btn-success" onclick="UiList.loadTable()">查询</button>
						</div>
						<div class="columns pull-right nopadding" style="width:150px;">
							<input id="end" type="text" class="laydate-icon form-control" placeholder="结束日期">
						</div>
						<div class="columns pull-right nopadding" style="vertical-align:middle;height:34px;line-height:34px;padding:0 5px;">至</div>
						<div class="columns pull-right nopadding" style="width:150px;">
							<input id="begin" type="text" class="laydate-icon form-control" placeholder="开始日期">
						</div>
					</div>
					<table id="dataTable" data-mobile-responsive="true">
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<%@ include file="/WEB-INF/adminui/include/script.jsp" %>
<script type="text/javascript">
$(function(){
	laydate({ 
		elem: '#begin'
	});
	laydate({ 
		elem: '#end'
	});
	UiList.render({
		treeUrl: '${path}/parkjstree/menudatatype.json?module=plant&blockType=3',
		tableConfig:{
			url: "${path}/plant/listdata.json?plantType=3",
			idfield: 'plantid',
			columns: [
				{checkbox : true},
				{field : 'blockName', title : '地块名称'},
				{field : 'cropName', title : '加工产品'},
				{field : 'beginTime', title : '开始日期', formatter : function(value, row, index) {
					return formatDate(value, 'yyyy-MM-dd');
				}},
				{field : 'endTime', title : '完成日期', formatter : function(value, row, index) {
					return formatDate(value, 'yyyy-MM-dd');
				}},
				{field : 'isCurrent', title : '当前加工', formatter : function(value, row, index) {
					switch(''+value){
					case '0': return '历史加工';
					case '1': return '当前加工';
					}
					return ''+value;
				}},
				{field : 'plantStatus', title : '加工状态', formatter : function(value, row, index) {
					switch(''+value){
					case '0': return '未完成';
					case '1': return '已完成';
					}
					return ''+value;
				}},
				{field : 'isuse', title : '地块状态', formatter : function(value, row, index) {
					switch(''+value){
					case '0': return '闲置';
					case '1': return '正常';
					}
					return ''+value;
				}},
				{field : 'plantid', title : '操作', align : 'center', formatter : function(value, row, index) {
					var s = '';
					<qx:perm code="plant_JG_EDIT">
					s += '<a class="btn btn-primary btn-sm" href="javascript:;" title="修改" onclick="edit(\''+value+'\')">修改</a>';
					</qx:perm>
					return s;
				}}
			]
		},
		tableParams: function(){//搜索条件
			return {begin: $("#begin").val(), end: $("#end").val()};
		}
	});
	
});

function add(){
	UiList.open('${path}/plant/add.do', '添加加工信息');
}
function del(){
	UiList.dialog('${path}/plant/delete.json?plantType=3', '您确定要删除选中的加工信息吗？', '删除加工信息成功.');
}
function edit(id){
	UiList.open('${path}/plant/edit.do?plantid='+id, '修改加工信息');
}
</script>
</body>
</html>